package bb.lanxing.lib.devices.base.converter;

import android.bluetooth.BluetoothGattCharacteristic;
import bb.lanxing.lib.devices.base.CharacteristicConverter;
import bb.lanxing.lib.devices.ble.device.StandardPowerrateDevice;
import bb.lanxing.lib.devices.core.ble.IGattClient;
import android.util.Log;
import java.util.UUID;
import bb.lanxing.lib.devices.ble.BLEAttributes;

public class PowerrateConverter implements CharacteristicConverter {
    final static private boolean DebugPower = false;
    public void onPowerrate(int i, int i2) {
    }

    @Override
    public final void convert(IGattClient iGattClient, BluetoothGattCharacteristic bluetoothGattCharacteristic) {
        int intValue;
        if (bluetoothGattCharacteristic.getUuid().equals(UUID.fromString(BLEAttributes.BLE_CYCLING_POWER_CHAR_MEASURE))) {
            if(DebugPower){
                intValue = bluetoothGattCharacteristic.getIntValue(BluetoothGattCharacteristic.FORMAT_UINT8, 1);;
            }else {
                intValue = bluetoothGattCharacteristic.getIntValue(BluetoothGattCharacteristic.FORMAT_SINT16, 2);
            }
            onPowerrate(iGattClient.getType(), intValue);
        }
    }
}